//log
eclipse.runtime.include("../log/log.eclipse.js");
eclipse.runtime.include("../parse/parse.eclipse.js");
eclipse.runtime.include("../format/format.eclipse.js");
log.log('include run');

/**
 * 启动程序
 * 
 * @param {String}
 *            filePath
 */
var Run = function(filePath) {
	this.parse = new Parse(filePath);
}

/**
 * 格式化方法
 */
Run.prototype.run = function(opt) {
	var txt = new Format(opt).format(this.parse.parse(opt)), file, filePath, logStatus;
	if (opt['mode'] === 'normal') {
		file = this.parse.file;
		filePath = file.filePath;
		file.filePath = opt['output'] || '';
		file.write(txt);
		file.filePath = filePath;
	} else {
		logStatus = log.status();
		log.switchover(true);
		log.log(txt);
		log.switchover(logStatus);
	}
	return txt;
};

// 运行
new Run().run({
	tabStr : '\t',
	debug : false,
	mode : 'normal',
	lineMinWidth : 120,
	// output:'C:/Users/wuqinglong/git/JspFormat/src/test/test.html
	noFormat : false
});
